package com.example.Android0115;

import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import java.util.Stack;

public class MyActivity extends Activity {
    private static final String ACTION_RECV_MSG = "com.example.Android0115.action.RECEIVE_MESSAGE";
    private Button loginbtn ;
    private EditText et_username;
    private EditText et_password;
    private String userName;
    private String passWord;
    private MessageReceiver receiver;
    /**
     * Called when the activity is first created.
     */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        initView();
    }

    private void initView(){
        et_username = (EditText)findViewById(R.id.userName_edit);
        et_password = (EditText)findViewById(R.id.passWord_edit);
        loginbtn = (Button)findViewById(R.id.btn1);
        loginbtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(matchLoginMsg()){
                    Intent msgIntent = new Intent(MyActivity.this,)
                }
            }
        });
    }

    protected boolean matchLoginMsg(){
        userName = et_username.getText().toString().trim();
        passWord = et_password.getText().toString().trim();
        if(userName.equals("")){
            Toast.makeText(MyActivity.this,"账号不能为空",Toast.LENGTH_SHORT).show();
            return false;
        }
        if(passWord.equals("")){
            Toast.makeText(MyActivity.this,"密码不能为空",Toast.LENGTH_SHORT).show();
        }
        return true;
    }

    /**
     * 接收广播类
     */
    public class MessageReceiver extends BroadcastReceiver{
        @Override
        public void onReceive(Context context, Intent intent) {
            String message = intent.getStringExtra(resule);
        }
    }
}
